package com.inmobi.re.container;

import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.net.http.SslError;
import android.os.Message;
import android.webkit.SslErrorHandler;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.inmobi.commons.internal.Log;
import com.inmobi.re.configs.Initializer;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;

class b extends WebViewClient
{
  b(IMWebView paramIMWebView)
  {
  }

  public void onLoadResource(WebView paramWebView, String paramString)
  {
    Log.debug("IMRE_3.7.0", "IMWebView-> onLoadResource:" + paramString);
    try
    {
      if (IMWebView.a(this.a) != null)
        IMWebView.a(this.a).onLoadResource(paramWebView, paramString);
      if ((paramString != null) && (paramString.contains("/mraid.js")) && (!this.a.getUrl().equals("about:blank")) && (!this.a.getUrl().startsWith("file:")))
      {
        Log.debug("IMRE_3.7.0", "IMWebView-> onLoadResource:Hippy, Mraid ad alert!...injecting mraid and mraidview object at " + paramWebView.getUrl());
        String str = this.a.getUrl();
        if (!IMWebView.d(this.a).contains(str))
          IMWebView.d(this.a).add(str);
        if (!this.a.mraidLoaded)
          this.a.injectJavaScript(Initializer.getMRAIDString());
        this.a.mraidLoaded = true;
      }
      return;
    }
    catch (Exception localException)
    {
      Log.internal("IMRE_3.7.0", "Cannot load resource", localException);
    }
  }

  public void onPageFinished(WebView paramWebView, String paramString)
  {
    Log.debug("IMRE_3.7.0", "IMWebView-> onPageFinished, url: " + paramString);
    if (IMWebView.a(this.a) != null)
      IMWebView.a(this.a).onPageFinished(paramWebView, paramString);
    try
    {
      if ((IMWebView.d(this.a).contains(paramString)) && (!this.a.mraidLoaded))
        this.a.injectJavaScript(Initializer.getMRAIDString());
      Log.debug("IMRE_3.7.0", "IMWebView-> Current State:" + IMWebView.b(this.a));
      if (IMWebView.b(this.a) == IMWebView.ViewState.LOADING)
      {
        this.a.injectJavaScript("window.mraid.broadcastEvent('ready');");
        Log.debug("IMRE_3.7.0", "IMWebView-> Firing ready event at " + paramWebView);
        if (this.a.mOriginalWebviewForExpandUrl != null)
          this.a.setState(IMWebView.ViewState.EXPANDED);
        while (true)
        {
          if (((!this.a.mIsInterstitialAd) || (this.a.mWebViewIsBrowserActivity)) && (this.a.getVisibility() == 4))
            this.a.setVisibility(0);
          if ((IMWebView.e(this.a) != null) && (!IMWebView.c(this.a).get()))
            IMWebView.e(this.a).sendToTarget();
          if (IMWebView.f(this.a) == null)
            break;
          IMWebView.f(this.a).sendToTarget();
          return;
          this.a.setState(IMWebView.ViewState.DEFAULT);
        }
      }
    }
    catch (Exception localException)
    {
      Log.debug("IMRE_3.7.0", "Exception in onPageFinished ", localException);
    }
  }

  public void onPageStarted(WebView paramWebView, String paramString, Bitmap paramBitmap)
  {
    this.a.setState(IMWebView.ViewState.LOADING);
    Log.debug("IMRE_3.7.0", "IMWebView-> onPageStarted url: " + paramString + " p " + this.a.getParent());
    if (this.a.getParent() == null)
      IMWebView.a(this.a, true);
    if (IMWebView.a(this.a) != null)
      IMWebView.a(this.a).onPageStarted(paramWebView, paramString, paramBitmap);
    this.a.mraidLoaded = false;
  }

  public void onReceivedError(WebView paramWebView, int paramInt, String paramString1, String paramString2)
  {
    Log.debug("IMRE_3.7.0", "IMWebView-> error: " + paramString1);
    if (IMWebView.a(this.a) != null)
      IMWebView.a(this.a).onReceivedError(paramWebView, paramInt, paramString1, paramString2);
    try
    {
      if ((IMWebView.b(this.a) == IMWebView.ViewState.LOADING) && (this.a.mListener != null) && (!IMWebView.c(this.a).get()))
        this.a.mListener.onError();
      IMWebView.a(this.a, null);
      return;
    }
    catch (Exception localException)
    {
      Log.debug("IMRE_3.7.0", "Exception in webview loading ", localException);
    }
  }

  @TargetApi(14)
  public void onReceivedSslError(WebView paramWebView, SslErrorHandler paramSslErrorHandler, SslError paramSslError)
  {
    IMWebView.a(this.a, paramSslErrorHandler, paramSslError);
  }

  public boolean shouldOverrideUrlLoading(WebView paramWebView, String paramString)
  {
    Log.debug("IMRE_3.7.0", "IMWebView-> shouldOverrideUrlLoading, url:" + paramString + "webview id" + paramWebView);
    try
    {
      if (this.a.mWebViewIsBrowserActivity)
      {
        if ((paramString.startsWith("http:")) || (paramString.startsWith("https:")))
        {
          this.a.doHidePlayers();
          return false;
        }
        IMWebView.a(this.a, paramString);
        return true;
      }
    }
    catch (Exception localException)
    {
      Log.internal("IMRE_3.7.0", "Should override exception", localException);
      return false;
    }
    IMWebView.a(this.a, paramString);
    return true;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.inmobi.re.container.b
 * JD-Core Version:    0.6.2
 */